package com.wxm.jwt.client.util;

import com.wxm.jwt.client.properties.JWTAuthClient;
import com.wxm.jwt.client.properties.JWTByteAuthClient;
import com.wxm.jwt.client.properties.JWTFileAuthClient;
import lombok.Data;
import java.io.File;

/**
 * <p>
 *      客户端认证配置构建工厂
 * </p>
 *
 * @author: wxm
 * @Date: 2021/10/6
 */
@Data
public class JWTAuthClientFactory {
    private JWTAuthClientFactory(){}

    /**
     * 构建JWTAuthClient
     * @param clazz 类型
     * @param o 参数
     * @return JWTAuthClient
     */
    public static JWTAuthClient buildJWTAuthClient(Class<? extends JWTAuthClient> clazz, Object o){
        if (clazz.equals(JWTByteAuthClient.class)){
            return new JWTByteAuthClient((byte[]) o);
        }else if (clazz.equals(JWTFileAuthClient.class)){
            return new JWTFileAuthClient((File) o);
        }
        return null;
    }
}
